package com.zzty.demo.controller;


import com.zzty.demo.entity.Clazz;
import com.zzty.demo.service.ClazzService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/clazz")
public class ClazzController {
    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ClazzController.class);

    @Autowired
    ClazzService clazzService;

    @RequestMapping(value = "/allClazz")
    public List allClazz() throws Exception{
        List<Clazz> clazzes=new ArrayList<>();
        clazzes=clazzService.allClazz();
        logger.info("clazz is :"+clazzes.toString());
        return clazzes;
    }

    @RequestMapping("/getClazz")
    public List<Clazz> getClazz() {
        List<Clazz> clazzes = clazzService.getClazz();
        logger.info("/clazz/getClazz clazzs: " + clazzes.toString());
        System.out.println("CC clazzs: " + clazzes.toString());
        return clazzes;
    }
}
